﻿#include<iostream>
#include<unordered_map>
#include<unordered_set>

int main() {
	std::unordered_map<int, std::string> map;
	std::unordered_set<std::string> set;

	//unordered_map常规操作
	//插入
	map[1] = "apple";
	map[2] = "banana";
	//查找
	auto ele = map.find(1);//找不到时返回迭代器

	//遍历
	for (const auto& pair : map) {
		std::cout << "key:" << pair.first << ",value:" << pair.second << std::endl;
		//pair.second = 3;
	}
	//删除
	map.erase(1);
	//获取大小
	int size = map.bucket_count();

	//unordered_set常规操作
	//插入
	set.insert("apple");
	//判断是否存在
	bool isExists = set.find("apple") != set.end();
	//删除
	set.erase("apple");
	//遍历
	for (const auto& key : set) {
		std::cout << "unique key:" << key << std::endl;
	}

	std::cout << "Cpp hash table implement" << std::endl;
}